//
//  AXFSelecteCellCarView.m
//  AIXF
//
//  Created by Macx on 2017/7/14.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFSelecteCellCarView.h"
#import "AXFAccountManager.h"
@interface AXFSelecteCellCarView ()
@property (weak, nonatomic) IBOutlet UIButton *reduceBtn;
@property (weak, nonatomic) IBOutlet UIButton *increseBtn;
@property (weak, nonatomic) IBOutlet UILabel *countNum;
@property (weak, nonatomic) IBOutlet UIButton *carBtn;
@property (weak, nonatomic) IBOutlet UIButton *totalNumBtn;

@end

@implementation AXFSelecteCellCarView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        
        self = [[NSBundle mainBundle] loadNibNamed:@"AXFSelecteCellCarView" owner:nil options:nil].lastObject;
    }
    return self;
}
- (IBAction)reduceAction:(id)sender {
    _AXFAccountManager.goodsNum--;
    self.model.count--;
    self.num = self.model.count;
    
}
- (IBAction)increaseAction:(id)sender {
    _AXFAccountManager.goodsNum++;
    self.model.count++;
    self.num = self.model.count;
}


- (void)setModel:(AXFHomeFirstSellModel *)model
{
    _model = model;
    self.num = model.count;
//    
//    self.countNum.hidden = !model.count;
//    self.reduceBtn.hidden = !model.count;
    self.totalNumBtn.hidden = !_AXFAccountManager.goodsNum;
//    self.countNum.text = [NSString stringWithFormat:@"%d",model.count];
    [self.totalNumBtn setTitle:[NSString stringWithFormat:@"%zd",_AXFAccountManager.goodsNum] forState:UIControlStateNormal];

}
- (void)setNum:(int)num
{
    _num = num;
    self.countNum.hidden = !num;
    self.reduceBtn.hidden = !num;
    self.totalNumBtn.hidden = !num;
    self.countNum.text = [NSString stringWithFormat:@"%d",_model.count];
    [self.totalNumBtn setTitle:[NSString stringWithFormat:@"%zd",_AXFAccountManager.goodsNum] forState:UIControlStateNormal];
    [[NSNotificationCenter defaultCenter] postNotificationName:kIncrementGoodsNumNotification object:nil];
}

@end
